package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 通过UserService来注入对象类型的数据
 *
 */
@Service
public class UserService {
    @Value("业务名称")
    //业务名称
    private String name;
    //我想注入UserDao对象使用Autowired注入对象，接口类型
    /**
     * Autowied叫做自动装配
     * 1.注入对象【Java类型】或者接口【interfa】类型的数据
     * 2.添加的位置
     *   2.1 属性上
     *   2.2 set方法上
     *   2.3 构造方法上
     */
    //@Autowired
    private UserDao userDao;

    //@Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
